<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>换背景颜色</title>
    <style>
        #button1 {
            background-color: red;
        }
        
        #button2 {
            background-color: yellow;
        }
        
        #button3 {
            background-color: blue;
        }
    </style>
    <script>
        window.onload = function() {

            button1.onclick = function() {
                var test = body1.style.backgroundColor = "red";
                button1.innerHTML = test;
                /* alert("2"); */
            }
            button2.onclick = function() {
                var test = body1.style.backgroundColor = "yellow";
                button1.innerHTML = test;
            }
            button3.onclick = function() {
                var test = body1.style.backgroundColor = "blue";
                button1.innerHTML = test;
            }

        }
    </script>
</head>

<body id="body1">
    <input type="button" value="button1" id="button1">
    <input type="button" value="button2" id="button2">
    <input type="button" value="button3" id="button3">
</body>

</html>
